package com.shanzmoo.platform.manage.api.web.product;

import com.shanzmoo.base.bean.PageRespBase;
import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.db.module.product.domain.dto.ProductSaveDto;
import com.shanzmoo.db.module.product.domain.dto.ProductUpdateDto;
import com.shanzmoo.db.module.product.domain.query.ProductQueryVO;
import com.shanzmoo.db.module.product.domain.vo.ProductVO;
import com.shanzmoo.platform.manage.api.manager.product.ProductSpuManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;

/**
 * 商品spumanager
 * @author xueqz
 */
@Api(tags = "商品管理系统-spu")
@RestController
@RequestMapping("/api/product/spu")
public class ProductSpuController {
    @Autowired
    private ProductSpuManager productSpuManager;

    @ApiOperation(value = "商品列表")
    @PostMapping("/getSpuList")
    public SHttpResponse<PageRespBase<ProductVO>> getSpuList(@RequestBody ProductQueryVO productQueryVO) {//@Valid @RequestBody
        return productSpuManager.getSpuList(productQueryVO);
    }

    @ApiOperation(value = "商品上下架操作")
    @GetMapping("/operationSpu")
    public SHttpResponse<Boolean> operationSpu(Integer id,Boolean shelvesMark) {

        return productSpuManager.operationSpu(id,shelvesMark);
    }

    @ApiOperation(value = "商品保存操作")
    @PostMapping("/saveSpu")
    public SHttpResponse<Boolean> saveSpu(@RequestBody ProductSaveDto productSaveDto) {

        return productSpuManager.saveSpu(productSaveDto);
    }

    @ApiOperation(value = "商品更新操作")
    @PostMapping("/updateSpu")
    public SHttpResponse<Boolean> updateSpu(@RequestBody ProductUpdateDto productUpdateDto) {

        return productSpuManager.updateSpu(productUpdateDto);
    }

//    @ApiOperation(value = "获取商品发布常量对象集")
//    @GetMapping("/getStaticProductData")
//    public SHttpResponse<Map> getStaticProductData() {
//
//        return productSpuManager.getStaticProductData();
//    }

    @ApiOperation(value = "获取商品编辑/查看详情信息")
    @GetMapping("/getSpuDetailBySpuId")
    public SHttpResponse<ProductUpdateDto> getSpuDetailBySpuId(Integer spuId) {

        return productSpuManager.getSpuDetailBySpuId(spuId);
    }



}
